﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;

namespace Pilot_Service
{
    public partial class Pilot_Service : ServiceBase
    {
        private static NLog.Logger log = NLog.LogManager.GetCurrentClassLogger();

        public Pilot_Service()
        {
            log.Info("Pilot_Service()");
            InitializeComponent();

            if (!System.Diagnostics.EventLog.SourceExists("Pilot_Service"))
            {
                System.Diagnostics.EventLog.CreateEventSource("Pilot_Service", "Pilot");
            }

            eventLog1.Source = "Pilot_Service";

            eventLog1.Log = "Pilot";
        }

        protected override void OnStart(string[] args)
        {
            log.Info("OnStart()");
            eventLog1.WriteEntry("my service started"); 
        }

        protected override void OnStop()
        {
            log.Info("OnStop()");
            eventLog1.WriteEntry("my service stoped");
        }

        protected override void OnContinue()
        {
            log.Info("OnStop()");
            eventLog1.WriteEntry("my service is continuing in working");
        }

        private void eventLog1_EntryWritten(object sender, EntryWrittenEventArgs e)
        {

        }
    }
}
